﻿Imports IWshRuntimeLibrary
Imports File = System.IO.File
Public Class NewUi
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
    Private Sub NewUI_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim commandLineArgs As ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
        Dim rdp As Boolean = False
        ' ReSharper disable once LocalVariableHidesMember
        Dim domain As String
        Dim primary As Boolean = False
        Dim user As String = Nothing
        If commandLineArgs.Count > 0 Then
            For i As Integer = 0 To commandLineArgs.Count - 1
                If UCase(commandLineArgs(i)).Contains("RDP") Then
                    rdp = True
                    domain = Environment.GetEnvironmentVariable("USERDOMAIN").ToString()
                    user = Environment.GetEnvironmentVariable("USERNAME").ToString()
                End If
                If UCase(commandLineArgs(i)).Contains("PRIMARY") Then
                    primary = True
                End If
            Next
        Else

        End If
        lblseardp.Text = rdp
        If primary Then
            cbseaseatype.Text = "Primary Device"
        Else
            cbseaseatype.Text = "Last User Logon"
        End If
        If rdp Then
            CheckUserName.Checkusername(ConnectSmsProvider.Connect, user, domain, False, rdp, cbseaseatype.Text.ToString())
        Else
            Try
                For Each item In From item1 In GetDomains.Getdoms() Where Not item1 = Nothing
                    cbdomlist.Items.Add(item)
                Next
                Resetform()
            Catch ex As Exception
                cbdomlist.Items.Add(Environment.GetEnvironmentVariable("USERDOMAIN"))
                'MessageBox.Show("No Domains detected, Please define domain when searching")
                Resetform()
            End Try
        End If
    End Sub

    Private Sub btseasearch_Click(sender As Object, e As EventArgs) Handles btseasearch.Click
        If Not tbseacompname.Text = "" Then
            tslbl.Text = "Searching for " & tbseacompname.Text
            GetSMSProvideData.Getcomsys(ConnectSmsProvider.Connect, "Name = '" & tbseacompname.Text & "'", lblseardp.Text)
        ElseIf Not tbseasernum.Text = "" Then
            tslbl.Text = "Searching for " & tbseasernum.Text
            CheckSerialNum.Checkserialnum(ConnectSmsProvider.Connect, tbseasernum.Text, lblseardp.Text)
        ElseIf Not tbseauname.Text = "" Then
            tslbl.Text = "Searching for " & tbseauname.Text & " in " & cbdomlist.Text & " Domain"
            CheckUserName.Checkusername(ConnectSmsProvider.Connect, tbseauname.Text, cbdomlist.Text.ToString(), True, lblseardp.Text, cbseaseatype.Text.ToString())
        End If
    End Sub

    Private Sub tbseauname_KeyDown(sender As Object, e As KeyEventArgs) Handles tbseauname.KeyDown
        If GetAsyncKeyState(13) Then
            tslbl.Text = "Searching for " & tbseauname.Text & " in " & cbdomlist.Text & " Domain"
            CheckUserName.Checkusername(ConnectSmsProvider.Connect, tbseauname.Text, cbdomlist.Text.ToString(), True, lblseardp.Text, cbseaseatype.Text.ToString())
        End If
    End Sub

    Private Sub dgseamulticomp_DoubleClick(sender As Object, e As EventArgs) Handles dgseamulticomp.DoubleClick
        panseamulticomp.Visible = False
        pansea.Visible = True
        tslbl.Text = "Searching for " & dgseamulticomp.SelectedCells.Item(0).Value.ToString()
        GetSMSProvideData.Getcomsys(ConnectSmsProvider.Connect, "Name = '" & dgseamulticomp.SelectedCells.Item(0).Value.ToString() & "'", lblseardp.Text)
    End Sub

    Private Sub dgseamulticomp_KeyPress(sender As Object, e As KeyPressEventArgs) Handles dgseamulticomp.KeyPress
        If GetAsyncKeyState(13) Then
            panseamulticomp.Visible = False
            pansea.Visible = True
            tslbl.Text = "Searching for " & dgseamulticomp.SelectedCells.Item(0).Value.ToString()
            GetSMSProvideData.Getcomsys(ConnectSmsProvider.Connect,
                                        "Name = '" &
                                        dgseamulticomp.SelectedCells.Item(0).Value.ToString() & "'", lblseardp.Text)
        End If
    End Sub

    Public Sub Sinfillform(ByVal objcompinfo As List(Of String))
        For Each client In objcompinfo
            tslbl.Text = "Results populating, Please Wait."
            Dim clientinfo As Object = Split(client.ToString, "|")
            If Not clientinfo(0).ToString() = "" Then
                tbseauname.Text = Split(clientinfo(0).ToString(), "\")(1).ToString()
                cbdomlist.Text = Split(clientinfo(0).ToString(), "\")(0).ToString()
                '### User labels
                lblresuunameres.Text = clientinfo(0).ToString
                Dim usersms() As String
                usersms = Split(GetUserOU.GetUserOU(clientinfo(0).ToString, ConnectSmsProvider.Connect), "|")
                lblresuuoures.Text = usersms(0).ToString()
                'lblresuupnres.Text = usersms(1).ToString()
                Dim usrad() As String
                usrad = Split(CheckPwd.Checkpwd(clientinfo(0).ToString), "|")
                lblresupasexres.Text = usrad(0).ToString()
                lblresupasslores.Text = usrad(1).ToString()
                lblresuphnumres.Text = usrad(2).ToString()
                lblresumailres.Text = usrad(3).ToString()
                lblresuupnres.Text = usrad(4).ToString()
                lblresuhomeres.Text = usrad(5).ToString()
                btresurespwd.Enabled = True
                btresuunlck.Enabled = True
                tcres.SelectTab(0)
            Else
                lblresuunameres.Text = "No User found for Computer"
                lblresuuoures.Text = "No User found for Computer"
                lblresupasexres.Text = "No User found for Computer"
                lblresupasslores.Text = "No User found for Computer"
                lblresuphnumres.Text = "No User found for Computer"
                lblresumailres.Text = "No User found for Computer"
                lblresuupnres.Text = "No User found for Computer"
                tcres.SelectTab(1)
            End If

            '#### computer labels
            If clientinfo(1).ToString = "" Then lblresccomnameres.Text = "No Computer Found" Else lblresccomnameres.Text = clientinfo(1).ToString
            If clientinfo(2).ToString = "" Then lblrescsernumres.Text = "No Serial Number found" Else lblrescsernumres.Text = clientinfo(2).ToString
            If clientinfo(3).ToString = "" Then lblrescmodres.Text = "No Model found" Else lblrescmodres.Text = clientinfo(3).ToString
            If clientinfo(4).ToString = "" Then lblrescmacaddres.Text = "No MAC Address found" Else lblrescmacaddres.Text = clientinfo(4).ToString
            If clientinfo(6).ToString = Nothing Then lblrescbderes.Text = "No BitLocker Key Found" Else lblrescbderes.Text = GetBdeKeys.ReturnRecoveryKey("LDAP://" & clientinfo(6).ToString)
            If clientinfo(7).ToString = Nothing Then lblrescipaddres.Text = "No IP Address found" Else lblrescipaddres.Text = Trim(clientinfo(7).ToString)
            If clientinfo(8).ToString = Nothing Then lblrescmanures.Text = "No Manufacture found" Else lblrescmanures.Text = clientinfo(8).ToString
            If clientinfo(9).ToString = Nothing Then lblrescsoures.Text = "No System OU Found" Else lblrescsoures.Text = clientinfo(9).ToString
            If clientinfo(10).ToString = Nothing Then lblrescosres.Text = "OS Version not found" Else lblrescosres.Text = clientinfo(10).ToString
            ' TODO Add in the handle for the getmapped drive results.
            'GetMappedDrives.GetMappedDrives(clientinfo(1).ToString())
            If Ping.Ping(clientinfo(1).ToString()) Then
                btrescclicent.Enabled = True
                btresccon.Enabled = True
                btresccshare.Enabled = True
                btrescrdp.Enabled = True
                lblrescadsiteres.Text = GetADSite.GetAdSite(clientinfo(1).ToString())
                lblrescuptres.Text = GetUptime.GetUptime(clientinfo(1).ToString())
                lblresccurusrres.Text = Currentusr.CheckCurrentUser(clientinfo(1).ToString())
                lblrescpendres.Text = PendingReboot.Reboot(clientinfo(1).ToString())
                For Each item In From item1 In GetShares.GetShares(clientinfo(1).ToString()) Where Not item1 = Nothing
                    cbresccshare.Items.Add(item)
                Next
                cbresccshare.Enabled = True
            Else
                lblrescadsiteres.Text = "Computer offline"
                lblrescuptres.Text = "Computer offline"
                lblresccurusrres.Text = "Computer offline"
            End If
            tabmain.SelectTab(1)
            btrescopyall.Enabled = True
            tslbl.Text = "Search Complete"
        Next
    End Sub

    Private Sub btresccon_Click(sender As Object, e As EventArgs) Handles btresccon.Click
        Dim path As String
        path = Environment.GetEnvironmentVariable("SMS_ADMIN_UI_PATH").ToString()
        If File.Exists(path & "\CmRcViewer.exe") Then
            Shell(
                Environment.GetEnvironmentVariable("SMS_ADMIN_UI_PATH").ToString() & "\CmRcViewer.exe " &
                lblresccomnameres.Text)
        Else
            tslbl.Text = "You might want to install SCCM 2012 to use Remote Control"
        End If
    End Sub

    Private Sub btrescclicent_Click(sender As Object, e As EventArgs) Handles btrescclicent.Click
        Dim processStartInfo As ProcessStartInfo
        processStartInfo = New ProcessStartInfo
        If File.Exists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Client Center for Configuration Manager 2012.lnk") Then '2012
            If Environment.OSVersion.Version.Major >= 6 Then ' Windows Vista or higher
                processStartInfo.Verb = "runas"
            Else
                ' No need to prompt to run as admin
            End If
            Dim wshell As WshShell = New WshShell
            Dim link As IWshShortcut
            link = wshell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Client Center for Configuration Manager 2012.lnk")
            'Shell(link.TargetPath & " " & tbComName.Text)
            processStartInfo.FileName = link.TargetPath
            processStartInfo.Arguments = lblresccomnameres.Text
            processStartInfo.WindowStyle = ProcessWindowStyle.Normal
            processStartInfo.UseShellExecute = True
            Process.Start(processStartInfo)
        ElseIf File.Exists("C:\Users\Public\Desktop\Client Center for Configuration Manager 2012.lnk") Then
            If Environment.OSVersion.Version.Major >= 6 Then ' Windows Vista or higher
                processStartInfo.Verb = "runas"
            Else
                ' No need to prompt to run as admin
            End If
            Dim wshell As WshShell = New WshShell
            Dim link As IWshShortcut
            link = wshell.CreateShortcut("C:\Users\Public\Desktop\Client Center for Configuration Manager 2012.lnk")
            'Shell(link.TargetPath & " " & tbComName.Text)
            processStartInfo.FileName = link.TargetPath
            processStartInfo.Arguments = lblresccomnameres.Text
            processStartInfo.WindowStyle = ProcessWindowStyle.Normal
            processStartInfo.UseShellExecute = True
            Process.Start(processStartInfo)
        ElseIf _
            File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Client Center for Configuration Manager 2012.appref-ms") Then
            'MessageBox.Show("Click Once installed")
            Shell("c:\program files\internet explorer\iexplore.exe http://sccmclictr.codeplex.com/releases/clickonce/SCCMCliCtrWPF.application?" & lblresccomnameres.Text)
        Else
            tslbl.Text = "You might want to install SMS client Center"
        End If
    End Sub

    Private Sub btresccshare_Click(sender As Object, e As EventArgs) Handles btresccshare.Click
        If Not cbresccshare.Text = "" Then
            Process.Start("Explorer.exe ", "\\" & lblresccomnameres.Text & "\" & cbresccshare.Text)
            tslbl.Text = "Connecting to \\" & lblresccomnameres.Text & "\" & cbresccshare.Text
        End If
    End Sub

    Private Sub tbseacompname_KeyDown(sender As Object, e As KeyEventArgs) Handles tbseacompname.KeyDown
        If GetAsyncKeyState(13) Then
            tslbl.Text = "Searching for " & tbseacompname.Text
            GetSMSProvideData.Getcomsys(ConnectSmsProvider.Connect, "Name = '" & tbseacompname.Text & "'", lblseardp.Text)
        End If
    End Sub

    Private Sub tbseasernum_KeyDown(sender As Object, e As KeyEventArgs) Handles tbseasernum.KeyDown
        If GetAsyncKeyState(13) Then
            tslbl.Text = "Searching for " & tbseasernum.Text
            CheckSerialNum.Checkserialnum(ConnectSmsProvider.Connect, tbseasernum.Text, lblseardp.Text)
        End If
    End Sub

    Private Sub dgseamultiuser_DoubleClick(sender As Object, e As EventArgs) Handles dgseamultiuser.DoubleClick
        panseamultiuser.Visible = False
        pansea.Visible = True
        tbseauname.Text = dgseamultiuser.CurrentRow.Cells.Item("Username").Value.ToString()
        tslbl.Text = "Searching for " & tbseauname.Text & " in " & cbdomlist.Text & " Domain"
        CheckUserName.Checkusername(ConnectSmsProvider.Connect, dgseamultiuser.CurrentRow.Cells.Item("Username").Value.ToString(), dgseamultiuser.CurrentRow.Cells.Item("Domain").Value.ToString(), False, lblseardp.Text, cbseaseatype.Text.ToString())
    End Sub

    Private Sub dgseamultiuser_KeyDown(sender As Object, e As KeyEventArgs) Handles dgseamultiuser.KeyDown
        If GetAsyncKeyState(13) Then
            panseamultiuser.Visible = False
            pansea.Visible = True
            tbseauname.Text = dgseamultiuser.CurrentRow.Cells.Item("Username").Value.ToString()
            tslbl.Text = "Searching for " & tbseauname.Text & " in " & cbdomlist.Text & " Domain"
            CheckUserName.Checkusername(ConnectSmsProvider.Connect, dgseamultiuser.CurrentRow.Cells.Item("Username").Value.ToString(), dgseamultiuser.CurrentRow.Cells.Item("Domain").Value.ToString(), False, lblseardp.Text, cbseaseatype.Text.ToString())
        End If
    End Sub

    Private Sub btresurespwd_Click(sender As Object, e As EventArgs) Handles btresurespwd.Click
        tslbl.Text = "Unlocking " & lblresuuname.Text & " User account"
        ResetAdpwd.Unlock(lblresuunameres.Text)
    End Sub
    Private Sub Resetform()
        tslbl.Text = "Reseting form"
        tbseauname.Text = ""
        tbseacompname.Text = ""
        tbseasernum.Text = ""
        '### User labels
        lblresuunameres.Text = ""
        lblresuuoures.Text = ""
        lblresupasexres.Text = ""
        lblresupasslores.Text = ""
        lblresuphnumres.Text = ""
        lblresumailres.Text = ""
        lblresuupnres.Text = ""
        lblresuhomeres.Text = ""
        '#### computer labels
        lblresccomnameres.Text = ""
        lblrescsernumres.Text = ""
        lblrescmodres.Text = ""
        lblrescmacaddres.Text = ""
        lblrescbderes.Text = ""
        lblrescipaddres.Text = ""
        lblrescmanures.Text = ""
        lblrescsoures.Text = ""
        lblrescosres.Text = ""
        lblrescadsiteres.Text = ""
        lblrescuptres.Text = ""
        lblresccurusrres.Text = ""
        lblrescpendres.Text = ""
        btrescclicent.Enabled = False
        btrescrdp.Enabled = False
        btresccon.Enabled = False
        btresccshare.Enabled = False
        btresurespwd.Enabled = False
        btresuunlck.Enabled = False
        btrescopyall.Enabled = False
        dgseamulticomp.Rows.Clear()
        dgseamultiuser.Rows.Clear()
        cbdomlist.SelectedIndex = 0
        cbseaseatype.SelectedIndex = 0
        tcres.SelectedIndex = 0
        cbresccshare.Enabled = False
        cbresccshare.Items.Clear()
        tslbl.Text = "Ready for Search"
        tspb.Value = 100
        panseamultiuser.Visible = False
        panseamulticomp.Visible = False
        tspb.Maximum = 100
        tspb.Minimum = 0
        tpsea.Show()
    End Sub

    Private Sub btseareset_Click(sender As Object, e As EventArgs) Handles btseareset.Click
        Resetform()
    End Sub

    Private Sub btrescopyall_Click(sender As Object, e As EventArgs) Handles btrescopyall.Click
        tslbl.Text = "Copying all Results to clipboard"
        Clipboard.SetText("Captured on: " & Now() & vbCrLf _
                          & "#### Computer Details ####" & vbCrLf _
                          & "Computer Name: " & lblresccomnameres.Text & vbCrLf _
                          & "Serial Number: " & lblrescsernumres.Text & vbCrLf _
                          & "Model: " & lblrescmodres.Text & vbCrLf _
                          & "Manufacture: " & lblrescmanures.Text & vbCrLf _
                          & "IP Address: " & lblrescipaddres.Text & vbCrLf _
                          & "MAC Address: " & lblrescmacaddres.Text & vbCrLf _
                          & "Operating System: " & lblrescosres.Text & vbCrLf _
                          & "BitLocker Key: " & lblrescbderes.Text & vbCrLf _
                          & "System OU: " & lblrescsoures.Text & vbCrLf _
                          & "AD Site Name: " & lblrescadsiteres.Text & vbCrLf _
                          & "Uptime: " & lblrescuptres.Text & vbCrLf _
                          & "Current User: " & lblresccurusrres.Text & vbCrLf _
                          & "Pending Reboot:" & lblrescpendres.Text & vbCrLf _
                          & "#### User Details ####" & vbCrLf _
                          & "UserName: " & lblresuunameres.Text & vbCrLf _
                          & "Phone Number: " & lblresuphnumres.Text & vbCrLf _
                          & "Password Expiration Date: " & lblresupasexres.Text & vbCrLf _
                          & "Password Lockout Status: " & lblresupasslores.Text & vbCrLf _
                          & "OU of User: " & lblresuuoures.Text & vbCrLf _
                          & "Email Address: " & lblresumailres.Text & vbCrLf _
                          & "User Principle Name: " & lblresuupnres.Text)
    End Sub

    Private Sub lblresuunameres_DoubleClick(sender As Object, e As EventArgs) Handles lblresuunameres.DoubleClick
        Clipboard.SetText(lblresuunameres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresuphnumres_DoubleClick(sender As Object, e As EventArgs) Handles lblresuphnumres.DoubleClick
        Clipboard.SetText(lblresuphnumres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresupasexres_DoubleClick(sender As Object, e As EventArgs) Handles lblresupasexres.DoubleClick
        Clipboard.SetText(lblresupasexres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresupasslores_DoubleClick(sender As Object, e As EventArgs) Handles lblresupasslores.DoubleClick
        Clipboard.SetText(lblresupasslores.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresuuoures_DoubleClick(sender As Object, e As EventArgs) Handles lblresuuoures.DoubleClick
        Clipboard.SetText(lblresuuoures.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresumailres_DoubleClick(sender As Object, e As EventArgs) Handles lblresumailres.DoubleClick
        Clipboard.SetText(lblresumailres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresuupnres_DoubleClick(sender As Object, e As EventArgs) Handles lblresuupnres.DoubleClick
        Clipboard.SetText(lblresuupnres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresccomnameres_DoubleClick(sender As Object, e As EventArgs) Handles lblresccomnameres.DoubleClick
        Clipboard.SetText(lblresccomnameres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescsernumres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescsernumres.DoubleClick
        Clipboard.SetText(lblrescsernumres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescmodres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescmodres.DoubleClick
        Clipboard.SetText(lblrescmodres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescmanures_DoubleClick(sender As Object, e As EventArgs) Handles lblrescmanures.DoubleClick
        Clipboard.SetText(lblrescmanures.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescipaddres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescipaddres.DoubleClick
        Clipboard.SetText(lblrescipaddres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescmacaddres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescmacaddres.DoubleClick
        Clipboard.SetText(lblrescmacaddres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescosres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescosres.DoubleClick
        Clipboard.SetText(lblrescosres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescbderes_DoubleClick(sender As Object, e As EventArgs) Handles lblrescbderes.DoubleClick
        Clipboard.SetText(lblrescbderes.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescsoures_DoubleClick(sender As Object, e As EventArgs) Handles lblrescsoures.DoubleClick
        Clipboard.SetText(lblrescsoures.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescadsiteres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescadsiteres.DoubleClick
        Clipboard.SetText(lblrescadsiteres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescuptres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescuptres.DoubleClick
        Clipboard.SetText(lblrescuptres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblresccurusrres_DoubleClick(sender As Object, e As EventArgs) Handles lblresccurusrres.DoubleClick
        Clipboard.SetText(lblresccurusrres.Text)
        tslbl.Text = Clipboard.GetText() & " Copied to the Clipboard"
    End Sub

    Private Sub lblrescpendres_DoubleClick(sender As Object, e As EventArgs) Handles lblrescpendres.DoubleClick
        Clipboard.SetText(lblrescpendres.Text)
        tslbl.Text = lblrescpend.Text & " Copied to the Clipboard"
    End Sub

    Private Sub cbdomlist_KeyDown(sender As Object, e As KeyEventArgs) Handles cbdomlist.KeyDown
        If GetAsyncKeyState(13) Then
            If Not tbseauname.Text = Nothing Then
                tslbl.Text = "Searching for " & tbseauname.Text & " in " & cbdomlist.Text & " Domain"
                CheckUserName.Checkusername(ConnectSmsProvider.Connect, tbseauname.Text, cbdomlist.Text.ToString(), True, lblseardp.Text, cbseaseatype.Text.ToString())
            End If
        End If
    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        Process.Start("www.vigilant.it")
    End Sub

    Private Sub btresuunlck_Click(sender As Object, e As EventArgs) Handles btresuunlck.Click
        tslbl.Text = "Unlocking user account: " & lblresuunameres.Text
        Unlockaccount.Unlock(lblresuunameres.Text)
        tslbl.Text = "Unlocked user account: " & lblresuunameres.Text
    End Sub

    Private Sub btrescrdp_Click(sender As Object, e As EventArgs) Handles btrescrdp.Click
        Shell(
            Environment.GetEnvironmentVariable("systemroot").ToString() & "\system32\mstsc.exe /v:" &
            lblresccomnameres.Text)
    End Sub

    Private Sub tabmain_Click(sender As Object, e As EventArgs) Handles tabmain.Click
        If tabmain.SelectedIndex = 0 Then
            If pansea.Visible = False Then
                If MessageBox.Show("Reset Search?", "User Query Tool", MessageBoxButtons.YesNo) = DialogResult.Yes Then
                    Resetform()
                    pansea.Visible = True
                End If
            End If
        End If
    End Sub

    Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Process.Start("mailto:steven.hosking@vigilant.it")
    End Sub


End Class